//
//  ArticleListTableViewCell.m
//  WrittingAnimation
//
//  Created by mac on 2019/5/14.
//  Copyright © 2019 Yang. All rights reserved.
//

#import "ArticleListTableViewCell.h"

@interface ArticleListTableViewCell ()

@property (nonatomic, strong) UILabel *articleView;
@property (nonatomic, strong) UIButton *portraitView;
@property (nonatomic, strong) UIButton *transverseView;

@end

@implementation ArticleListTableViewCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _portraitView = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_portraitView];
        [_portraitView setTitle:@"纵向排版" forState:UIControlStateNormal];
        [_portraitView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_portraitView addTarget:self action:@selector(portraitViewAction) forControlEvents:UIControlEventTouchUpInside];
        _portraitView.titleLabel.font = [UIFont systemFontOfSize:12];
        [_portraitView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10);
            make.centerY.mas_equalTo(self.contentView.mas_centerY).mas_offset(0);
            make.width.mas_equalTo(40);
            make.height.mas_equalTo(40);
        }];
        
        _transverseView = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_transverseView];
        [_transverseView setTitle:@"横向排版" forState:UIControlStateNormal];
        [_transverseView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_transverseView addTarget:self action:@selector(transverseViewAction) forControlEvents:UIControlEventTouchUpInside];
        _transverseView.titleLabel.font = [UIFont systemFontOfSize:12];
        [_transverseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.portraitView.mas_left).mas_offset(-10);
            make.centerY.mas_equalTo(self.contentView.mas_centerY).mas_offset(0);
            make.width.mas_equalTo(self.portraitView.mas_width).mas_offset(0);
            make.height.mas_equalTo(self.portraitView.mas_height).mas_offset(0);
        }];
        
        _portraitView.titleLabel.numberOfLines = 0;
        _transverseView.titleLabel.numberOfLines = 0;
//        _portraitView.backgroundColor = [UIColor purpleColor];
//        _transverseView.backgroundColor = [UIColor magentaColor];
        
        _articleView = [[UILabel alloc] init];
        [self.contentView addSubview:_articleView];
        _articleView.numberOfLines = 0;
        _articleView.textColor = [UIColor blackColor];
        _articleView.font = [UIFont systemFontOfSize:15];
        [_articleView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10);
            make.right.mas_equalTo(self.transverseView.mas_left).mas_offset(-10);
            make.top.mas_equalTo(self.contentView.mas_top).mas_offset(5);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).mas_offset(-5);
        }];
        
    }
    return self;
}

-(void)portraitViewAction
{
    if (self.ActionBlock) {
        self.ActionBlock(YES);
    }
}

-(void)transverseViewAction
{
    if (self.ActionBlock) {
        self.ActionBlock(NO);
    }
}

-(void)setTitleString:(NSString *)titleString
{
    _titleString = titleString;
    _articleView.text = titleString;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
